var batch = 
'<div class="modal" id="batch" tabindex="-1" role="dialog" aria-hidden="true">'+
	'<div class="modal-dialog" style="width: 800px !important;">'+
		'<div class="modal-content">'+
			'<div class="modal-header">'+
				'<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>'+
				'<h4 class="modal-title">选择进货信息</h4>'+
				'<div class="form-box2">'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">开始日期：</label>'+
						'<input class="ipt-self4" type="text" name="purStartTime" id="purStartTime" value="" />'+
					'</div>'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">结束日期：</label>'+
						'<input class="ipt-self4" type="text" name="purEndTime" id="purEndTime" value="" />'+
					'</div>'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">进货编码：</label>'+
						'<input class="ipt-self1" type="text" name="purCode" id="purCode" value="" />'+
					'</div>'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">批&emsp;&emsp;次：</label>'+
						'<input class="ipt-self1" type="text" name="purBatchNo" id="purBatchNo" value="" />'+
					'</div>'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">&emsp;供货商：</label>'+
						'<input class="ipt-self3" type="text" name="purComsterName" id="purComsterName" value="" />'+
						'<input data-toggle="modal" data-target="#SelectCustomerFiles" class="ipt-btn1" type="button" name="" id="" value="" />'+
						// '<input class="ipt-self3" type="text" name="customerCode" id="ccomsterCode"  value="" style="display:none" />'+
						'</div>'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">运输车牌：</label>'+
							'<select class="ipt-self5" name="purCarNoCode" id="purCarNoCode">'+
								'<option value=""></option>'+
								'<option value="沪">沪</option>'+
								'<option value="鲁">鲁</option>'+
								'<option value="京">京</option>'+
								'<option value="粤">粤</option>'+
							'</select>'+
						'<input class="ipt-self6" type="text" name="purCarNo" id="purCarNo" value="" />'+
					'</div>'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">员工工号：</label>'+
						'<input class="ipt-self1" type="text" name="purUserId" id="purUserId" value="" />'+
					'</div>'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">进货类型：</label>'+
						'<select class="ipt-self2" name="purChaseType" id="purChaseType">'+
						'</select>'+
					'</div>'+
					// '<div class="have-ipt-box2 icheck-success icheck-inline">'+
					// 	'<div class="ipt-label2">交易状态：</div>'+
					// 	'<div class="radio-box1">'+
					// 		'<div class="icheck-success icheck-inline">'+
					// 		    '<input type="radio" id="radio1" name="radio1" checked="checked" />'+
					// 		    '<label for="radio1">全部</label>'+
					// 		'</div>'+
					// 		'<div class="icheck-success icheck-inline">'+
					// 		    '<input type="radio" id="radio2" name="radio1" />'+
					// 		    '<label for="radio2">启用</label>'+
					// 		'</div>'+
					// 		'<div class="icheck-success icheck-inline">'+
					// 		    '<input type="radio" id="radio3" name="radio1" />'+
					// 		    '<label for="radio3">禁用</label>'+
					// 		'</div>'+
					// 	'</div>'+
					// '</div>'+
					// '<div class="have-ipt-box2 icheck-success icheck-inline">'+
					// 	'<div class="ipt-label2">结账状态：</div>'+
					// 	'<div class="radio-box1">'+
					// 		// '<div class="icheck-success icheck-inline">'+
					// 		//     '<input type="radio" id="radio4" name="radio2" checked="checked" />'+
					// 		//     '<label for="radio4">全部</label>'+
					// 		// '</div>'+
					// 		// '<div class="icheck-success icheck-inline">'+
					// 		//     '<input type="radio" id="radio5" name="radio2" />'+
					// 		//     '<label for="radio5">启用</label>'+
					// 		// '</div>'+
					// 		// '<div class="icheck-success icheck-inline">'+
					// 		//     '<input type="radio" id="radio6" name="radio2" />'+
					// 		//     '<label for="radio6">禁用</label>'+
					// 		// '</div>'+
					// 	'</div>'+
					// '</div>'+
					'<div class="have-ipt-box2 icheck-success icheck-inline">'+
						'<div class="ipt-label2">有效状态：</div>'+
						'<div class="radio-box1">'+
							'<div class="icheck-success icheck-inline">'+
							    '<input type="radio" id="radioPur3" value="" name="purstatus" id="purstatus"  />'+
							    '<label for="radioPur3">全部</label>'+
							'</div>'+
							'<div class="icheck-success icheck-inline">'+
							    '<input type="radio" id="radioPur2" value="0" name="purstatus" id="purstatus" checked="checked"/>'+
							    '<label for="radioPur2">启用</label>'+
							'</div>'+
							'<div class="icheck-success icheck-inline">'+
							    '<input type="radio" id="radioPur1" value="1" name="purstatus" id="purstatus"/>'+
							    '<label for="radioPur1">禁用</label>'+
							'</div>'+
						'</div>'+
						'</div>'+
					'</div>'+
					'<div class="form-btn-box form-btn-box2">'+
						'<button class="btn-blue" id="selectPurJsBtn">'+
							'<img src="../img/btn-icon/search.png"/>'+
							'<span>查询</span>'+
						'</button>'+
						 '<button class="btn-green" id="Btn-close-batch">'+
						 	'<img src="../img/btn-icon/close.png"/>'+
						 	'<span>关闭</span>'+
						 '</button>'+
					'</div>'+
					'<table id="tablebatch"></table>'+
				'</div>'+
			'</div>'+
		'</div>'+
	'</div>'+
'</div>';
$('body').append(batch);

//	时间初试化
$('#startTime1').datetimepicker({
	minView: "month",
	language:  'zh-CN',
	format: 'yyyy-mm-dd',
	todayBtn:  1,
	autoclose: true
});
$('#endTime1').datetimepicker({
	minView: "month",
	language:  'zh-CN',
	format: 'yyyy-mm-dd',
	todayBtn:  1,
	autoclose: true
});
$("#tablebatch").bootstrapTable({ // 对应table标签的id
//	url: DOMAIN+'/v1/purchase'+isLogin,
	method: 'get',
	cache: false,
	striped: true,
	pagination: true,
	pageSize: 5,
	pageNumber: 1,
	pageList: [5, 10],
	search: false,
	showColumns: false, 
	clickToSelect: true,
	queryParams: queryParams,
	smartDisplay: false,
	columns: [{
		checkbox: true
	}, {
		field: "id",
		title: "id",
		align: "center",
		valign: "middle",
		sortable: "true",
		visible:false
	}, {
		field: "purchaseTime",
		title: "进货日期",
		align: "center",
		valign: "middle",
		sortable: "true"
	}, {
		field: "code",
		title: "进货编码",
		align: "center",
		valign: "middle",
		sortable: "true"
	}, {
		field: "batchNo",
		title: "批次号",
		align: "center",
		valign: "middle",
		sortable: "true"
	}, {
		field: "comsterCode",
		title: "供货商代码",
		align: "center",
		valign: "middle",
		sortable: "true"
	}, {
		field: "comsterName",
		title: "供货商名称",
		align: "center",
		valign: "middle",
		sortable: "true"
	},{
		field: "car",
		title: "车牌号",
		align: "center",
		valign: "middle",
		sortable: "true"
	},{
		field: "purchaseType",
		title: "进货类型",
		align: "center",
		valign: "middle",
		sortable: "true"
	},{
		field: "sumQuantity",
		title: "商品数量",
		align: "center",
		valign: "middle",
		sortable: "true"
	},{
		field: "sumWeight",
		title: "商品重量",
		align: "center",
		valign: "middle",
		sortable: "true"
	},{
		field: "sumMoney",
		title: "商品金额",
		align: "center",
		valign: "middle",
		sortable: "true"
	},{
		field: "sum",
		title: "笔数",
		align: "center",
		valign: "middle",
		sortable: "true"
	},{
		field: "comment",
		title: "备注",
		align: "center",
		valign: "middle",
		sortable: "true"
	},
	// {
	// 	field: "userId",
	// 	title: "员工工号",
	// 	align: "center",
	// 	valign: "middle",
	// 	sortable: "true"
	// },
	{
		field: "loginName",
		title: "员工工号",
		align: "center",
		valign: "middle",
		sortable: "true"
	},
	{
		field: "userName",
		title: "员工姓名",
		align: "center",
		valign: "middle",
		sortable: "true"
	},{
		field: "status",
		title: "当前状态",
		align: "center",
		valign: "middle",
		formatter: function(value,row,index) { 
			if(row.status==0){
				return "启用";
			}else if(row.status==1){
				return "禁用";
			}
		}
	}],
	onDblClickRow: function (row) {
		//得到双击后的数据data1
		  //$('#ghs-data').val(row.data1);
		  //alert(row.customerName);
		 
		  $("#pbatchNo").val(row.batchNo);
		  $("#pcustomerName").val(row.comsterName);
		  $("#pcomsterCode").val(row.comsterCode);
		 // $("#psumWeight").val(row.sumWeight);
		  $("#ppuchaseCode").val(row.code);
		  $("#cparentName").val();
		  $("#cparentId").val();
  		//模拟关闭弹框
  			$('#batch').click();
	},

	//>>>>>>>>>>>>>>导出excel表格设置
	showExport: true,
	showExport: true,
	  //是否显示导出按钮
	    buttonsAlign: "left",
	  //按钮位置
	    exportDataType: 'all',
	   //导出的方式 all全部 selected已选择的  basic', 'all', 'selected'.
	    Icons: 'glyphicon glyphicon-export',
	    exportTypes: ['excel', 'doc', 'xlsx', 'txt', ],
	  //导出文件类型
	    exportOptions: {       ignoreColumn: [0,0],  //忽略某一列的索引，id删除更新用用，不显示与导出
		      
		fileName: '导出数据表',
		  //文件名称设置
		      worksheetName: 'sheet1',
		  //表格工作区名称
		      tableName: '导出数据表',
		       // excelstyles: ['background-color', 'color', 'font-size', 'font-weight'], 设置格式
		    
	},
	//导出excel表格设置<<<<<<<<<<<<<<<<
	formatNoMatches: function() {
		return '没有找到匹配的记录';
	}
});
function queryParams(params) {
	var params = {};
	return params;
};
	

//查询
$("#selectPurJsBtn").click(function(){
//新查询参数
function queryParamNew(params) {
var params = {};
params.startTime = $("#purStartTime").val();
params.endTime = $("#purEndTime").val();
params.code = $("#purCode").val();
params.batchNo = $("#purBatchNo").val();
params.comsterName = $("#purComsterName").val();
params.carNoCode = $("#purCarNoCode").val();
params.carNo = $("#purCarNo").val();
params.userId = $("#purUserId").val()
params.purchaseType = $("#purchaseType").val();
params.deleteFlg = $("input[name='purstatus']:checked").val();
return params;
};
var url =DOMAIN+'/v1/purchase'+isLogin;
	$('#tablebatch').bootstrapTable(
	'refreshOptions',
	{
		url: url,
		//查询参数
		queryParams: queryParamNew
	}
);
})

//关闭
$("#Btn-close-batch").click(function(){
	$('#batch').click();
})

	
//打开选择框时查询
$('#batch').on('shown.bs.modal', function () {
	$('#tablebatch').bootstrapTable(
		'refreshOptions',
		{
			url: DOMAIN+'/v1/purchase'+isLogin,
		}
	);

})	